<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta zy-app-id="monitor">
  <title>Document</title>
</head>
<body zy-page-id="test">
  <script>
    (function() {
      const script = document.createElement('script');
      // cdn 地址
      // script.src = 'http://aliyun.com/xxx/zy-cli-monitor.js';
      script.src = './src/index.js';
      document.body.insertBefore(script, document.body.firstChild);
      script.onload = () => {
        const event = new CustomEvent('openMonitorScriptLoad');
        window.dispatchEvent(event);
      }
    })();
  </script>

  <script>
    window.addEventListener('openMonitorScriptLoad', () => {
      const monitor = window.ZyCliMonitor;
      monitor.registerBeforeCreateParams(function() {
        console.log('before create param');
      });

      monitor.registerBeforeUpload(function(params) {
        params['customer'] = 1;
        return params;
      })

      monitor.registerAfterupload(function(url, data) {
        console.log(url, data);
      })

      monitor.registerOnError(function(e) {
        console.log('exception', e);
      })

      monitor.collect();
    })
  </script>
</body>
</html>